<template>
  <section>
   <!--  <el-col :xs="6" :sm="6" :md="6" :lg="6" style="height:800px;overflow-y :auto;overflow-x :auto">
      <el-tree highlight-current :data="treedata" :props="defaultProps" @node-click="handleNodeClick" :default-expand-all="true" :expand-on-click-node="true">
      </el-tree>

    </el-col> -->
  <div style="display:flex;justify-content:space-between;width:100%;height:100%">
    <div style="width:20%;position:relative;">
      <div  style="position:absolute;width:100%;height:100%;overflow-y:auto;overflow-x:auto">
         <el-col  style="overflow:hidden;width:auto" >
        <el-tree  highlight-current :data="treedata" :props="defaultProps" @node-click="handleNodeClick" :default-expand-all="true" :expand-on-click-node="true">
        </el-tree>
      </el-col>
      </div>
    </div>
   <div style="width:80%;">
    <el-col >
      <!--工具条-->
      <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="filters">
          <el-row :gutter="40">
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.productname" placeholder="产品中文名(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.refereeId" placeholder="推荐人(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-select size="small" clearable style="width:100%;" v-model.trim="filters.branchCode" placeholder="分公司(选填)">
                <el-option v-for="(item,index) in filters.barchCodes" :key="index" :label="item.codeCname" :value="item.code"></el-option>
              </el-select>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.agreementNo" placeholder="业务关系代码(选填)"></el-input>
            </el-col>
          </el-row>

          <el-row :gutter="40">
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.policyNo" placeholder="保单号(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.proposalNo" placeholder="投保单号(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.paymentNo" placeholder="支付订单号(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.planName" placeholder="计划名称(选填)"></el-input>
            </el-col>
          </el-row>

          <el-row :gutter="40">
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-select size="small" clearable style="width:100%;" v-model.trim="filters.status" placeholder="订单状态(选填)">
                <el-option label="支付失败" value="0"></el-option>
                <el-option label="已支付" value="1"></el-option>
                <el-option label="未支付" value="2"></el-option>
                <el-option label="无效" value="3"></el-option>
                <el-option label="新保" value="4"></el-option>
                <el-option label="下发修改或拒保" value="5"></el-option>
                <el-option label="自动核保" value="6"></el-option>
                <el-option label="等待核保" value="7"></el-option>
                <el-option label="主动撤回" value="8"></el-option>
                <el-option label="查勘岗" value="9"></el-option>
                <el-option label="单证审核不通过" value="10"></el-option>
                <el-option label="待单证审核" value="11"></el-option>
                <el-option label="待绩效审核" value="12"></el-option>
                <el-option label="绩效审核不通过" value="13"></el-option>
                <el-option label="批退" value="14"></el-option>
                <el-option label="批改" value="15"></el-option>
                <el-option label="保单遗失" value="16"></el-option>
                <el-option label="保单注销" value="17"></el-option>
              </el-select>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-tooltip class="item" effect="dark" content="投保日期" placement="top">
                <el-date-picker size="small" style="width:100%;" v-model="filters.insuranceDate" type="daterange" align="left" placeholder="选择投保日期范围(选填)">
                </el-date-picker>
              </el-tooltip>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-tooltip class="item" effect="dark" content="支付日期" placement="top">
                <el-date-picker 
                    size="small" 
                    style="width:100%;" 
                    v-model="filters.payDate" 
                    type="daterange" 
                    align="left" 
                    placeholder="选择支付日期范围(选填)">
                </el-date-picker>
              </el-tooltip>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-tooltip class="item" effect="dark" content="订单创建时间" placement="top">
                <el-date-picker 
                    size="small" 
                    style="width:100%;" 
                    @change="dateChange"
                    v-model="filters.createTime" 
                    type="daterange" 
                    align="left" 
                    placeholder="选择订单创建日期范围(选填)">
                </el-date-picker>
              </el-tooltip>
            </el-col>
          </el-row>
          <el-row :gutter="40">
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" placeholder="请输入内容" v-model="filters.insureData">
                <el-select size="small" style="min-width:120px;" v-model.trim="filters.insureSelect" slot="prepend" placeholder="请选择投保人">
                  <el-option label="投保人姓名" value="1"></el-option>
                  <el-option label="投保人证件号" value="2"></el-option>
                </el-select>
              </el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" placeholder="请输入内容" v-model="filters.InsuredData">
                <el-select size="small" style="min-width:120px;" v-model.trim="filters.InsuredSelect" slot="prepend" placeholder="请选择被保人(选填)">
                  <el-option label="被保人姓名" value="1"></el-option>
                  <el-option label="被保人证件号" value="2"></el-option>
                </el-select>
              </el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.shareUid" placeholder="订单来源标识(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.callBackUrl" placeholder="回调地址(选填)"></el-input>
            </el-col>
          </el-row>
          <el-row :gutter="40">
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.successfulUrl" placeholder="成功跳转地址(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.orderNo" placeholder="订单号(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.dealUuid" placeholder="交易ID(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.refereeMobile" placeholder="推荐人手机号码(选填)"></el-input>
            </el-col>
          </el-row>
          <el-row :gutter="40">
            <!-- <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;"> -->
            <!-- <el-select size="small" clearable  style="width:100%;"  v-model.trim="filters.unitType" placeholder="客户单位类型">
                <el-option label="支付失败"  value="0"></el-option>
                <el-option label="已支付"  value="1"></el-option>
                <el-option label="未支付"  value="2"></el-option>
                <el-option label="无效"  value="3"></el-option>
            </el-select> -->
            <!-- </el-col> -->
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.userName" placeholder="用户编码(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.mobile" placeholder="用户手机号码(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.scoreUserName" placeholder="积分用户(选填)"></el-input>
            </el-col>
            <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
              <el-input size="small" style="width:100%;" v-model.trim="filters.scoreUserMobile" placeholder="积分用户手机号(选填)"></el-input>
            </el-col>
          </el-row>
          <el-row :gutter="40">
            <el-form-item style="float:right;margin-right:20px;">
              <el-button v-show="exportBtnVisible" size="small" type="primary" icon="upload2" @click="exportExcels">导出</el-button>
            </el-form-item>
            <el-form-item v-show="syntonyBtnVisible" style="float:right;">
              <el-button size="small" type="primary" icon="d-arrow-left" v-on:click="getcallBack">回调</el-button>
            </el-form-item>
            <el-form-item style="float:right;">
              <el-button size="small" v-show="resetBtnVisible" type="warning" icon="delete" v-on:click="getdelete">重置</el-button>
            </el-form-item>
            <el-form-item style="float:right;">
              <el-button v-show="queryBtnVisible" size="small" type="primary" icon="search" @click="getOrders(true)">查询</el-button>
            </el-form-item>
            <!-- <el-form-item style="float:right;">
              <el-button size="small" style="width:60px;height:28px;background:#f5fbff;border-color:#f5fbff;" v-on:click="getpass"></el-button>
            </el-form-item> -->

          </el-row>

          <!--  </el-col>
        <el-col :xs="16" :sm="10" :md="8" :lg="6"> -->

          <!-- </el-col> -->

          <!--   <el-form-item>
              <el-input v-model="filters.planName" placeholder="计划名称"></el-input>
          </el-form-item>
          <el-form-item>
              <el-input v-model="filters.planName" placeholder="计划名称"></el-input>
          </el-form-item> -->

          <!--  <el-form-item>
            <el-select style="width:150px;" v-model="filters.riskCode" placeholder="险种">
              <el-option  label="全部险种"  value=""  ></el-option>
              <el-option v-for="item in filters.riskCodes" :label="item.codeCname"  :value="item.code"  ></el-option>
            </el-select>
          </el-form-item> -->

          <!-- <el-form-item>
          <el-input v-model="filters.name" placeholder="姓名"></el-input>
        </el-form-item> -->

          <!-- <el-form-item>
          <el-button type="primary" @click="handleAdd">新增</el-button>
        </el-form-item> -->

        </el-form>
      </el-col>

      <!--列表-->
      <el-table :data="orders" stripe border :height="winHeight-200" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
        <el-table-column prop="id" label="订单ID" align="center" min-width="80" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="productName" label="产品名" align="center" min-width="180" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="orderNo" label="订单号" align="center" min-width="180" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="agreementNo" label="业务关系代码" align="center" min-width="140">
        </el-table-column>
        <el-table-column prop="proposalNo" label="投保单号" align="center" min-width="220" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="policyNo" label="保单号" align="center" min-width="220" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="userId" label="用户ID" align="center" min-width="130"> </el-table-column>
        <el-table-column prop="userName" label="用户名" align="center" min-width="120" :formatter="formatUserName">
        </el-table-column>
        <el-table-column prop="userMobile" label="用户手机号码" align="center" min-width="180" :formatter="formatUserMobile">
        </el-table-column>
        <el-table-column prop="scoreUserName" label="积分用户" align="center" min-width="120" :formatter="formatScoreUserName">
        </el-table-column>
        <el-table-column prop="scoreUserMobile" label="积分用户手机号" align="center" min-width="180" :formatter="formatScoreUserMobile">
        </el-table-column>
        <el-table-column prop="applicantName" label="投保人" align="center" width="100" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="idNo" label="投保人证件号" align="center" min-width="180" show-overflow-tooltip>
        </el-table-column>

        <!-- <el-table-column prop="carIds" label="被保人证件号" min-width="180" sortable>
      </el-table-column> -->
        <el-table-column prop="amount" label="保费" align="center" width="80" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="riskCode" label="险种" align="center" width="100" :formatter="formatRisk">
        </el-table-column>
        <!-- <el-table-column prop="planCode" label="计划编号" min-width="180" sortable>
      </el-table-column> -->
        <!--  <el-table-column prop="startDate" label="起保时间" min-width="180" sortable>
      </el-table-column>
      <el-table-column prop="endDate" label="终保时间" min-width="180" sortable>
      </el-table-column> -->
        <el-table-column prop="createTime" label="订单创建时间" align="center" min-width="180" sortable>
        </el-table-column>

        <el-table-column prop="refereeId" label="推荐人" align="center" width="100" :formatter="formatRefereeId">
        </el-table-column>
        <el-table-column prop="refereeMobile" label="推荐人手机号" align="center" min-width="180" :formatter="formatRefereeMobile">
        </el-table-column>
        <el-table-column prop="unitType" label="客户单位类型" align="center" min-width="160" :formatter="formatUnitType">
        </el-table-column>
        <el-table-column prop="dealUuid" label="交易ID" align="center" width="100" show-overflow-tooltip>
        </el-table-column>
        <!--  <el-table-column prop="updateTime" label="订单更新时间" min-width="180" sortable>
      </el-table-column> -->
        <!--  <el-table-column prop="remark" label="备注" min-width="180" sortable>
      </el-table-column>
      <el-table-column prop="orderDetail" label="订单详情" min-width="180" sortable>
      </el-table-column>
 -->
        <!-- <el-table-column prop="branchCode" label="机构" min-width="180" sortable>
      </el-table-column>
      <el-table-column prop="address" label="地址" min-width="180" sortable>
      </el-table-column> -->
        <el-table-column label="操作" fixed='right' align="center" width="150">
          <template scope="scope">
            <el-button v-show="detailBtnVisible" size="small" @click="handleDetail(scope.$index, scope.row)">详情</el-button>
            <el-button v-show="updateBtnVisible" type="warning" size="small" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
            <!--  <el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button> -->
          </template>
        </el-table-column>
      </el-table>

      <!--工具条-->
      <el-col :span="24" class="toolbar">
        <!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
        <!-- <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="20" :total="total" style="float:right;">
      </el-pagination> -->
        <label class="detailLabel">保费:</label>
        <span class="examineFonts">{{this.totalAmount}}</span>
        <label class="detailLabel">均保费:</label>
        <span class="examineFonts">{{this.avgAmount}}</span>
        <el-pagination style="float:right" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page" :page-sizes="[10, 20, 40, 80]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
        </el-pagination>
      </el-col>
    </el-col>
    </div>
  </div>  
    <!--详情界面-->
    <el-dialog title="详情" size="large" v-model="detailFormVisible" :close-on-click-modal="false">
      <el-form :model="detailForm" label-width="120px" ref="detailForm">
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单ID:" prop="productCname">
              <el-input v-model="detailForm.id" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单号:" prop="productCname">
              <el-input v-model="detailForm.orderNo" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户编码:" prop="productCname">
              <el-input v-model="detailForm.userId" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码:" prop="productCname">
              <el-input v-model="detailForm.agreementNo" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="状态:" prop="productCname">
              <el-input v-model="detailForm.status" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="保费:" prop="productCname">
              <el-input v-model="detailForm.amount" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="险种:" prop="productCname">
              <el-input v-model="detailForm.riskCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="计划编号:" prop="productCname">
              <el-input v-model="detailForm.planCode" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保人:" prop="productCname">
              <el-input v-model="detailForm.applicantName" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保人证件号:" prop="productCname">
              <el-input v-model="detailForm.idNo" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="起保时间:" prop="productCname">
              <el-input v-model="detailForm.startDate" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="终保时间:" prop="productCname">
              <el-input v-model="detailForm.endDate" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-for="(item,index) in detailForm.applicant" :key="index">
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item :label="'被保人'+(index+1)+':'" prop="productCname">
              <el-input v-model="item.name" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item :label="'被保人'+(index+1)+'证件号:'" prop="productCname">
              <el-input v-model="item.carId" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item :label="'被保人'+(index+1)+'职业:'" prop="productCname">
              <el-input v-model="item.occupation" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item :label="'被保人'+(index+1)+'手机号:'" prop="productCname">
              <el-input v-model="item.mobil" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单创建时间:" prop="productCname">
              <el-input v-model="detailForm.createTime" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单更新时间:" prop="productCname">
              <el-input v-model="detailForm.updateTime" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单支付时间:" prop="productCname">
              <el-input v-model="detailForm.payDate" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="备注:" prop="productCname">
              <el-input v-model="detailForm.remark" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单详情:" prop="productCname">
              <el-input v-model="detailForm.orderDetail" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="产品名:" prop="productCname">
              <el-input v-model="detailForm.productName" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐人:" prop="productCname">
              <el-input v-model="detailForm.refereeId" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="房屋所在地:" prop="productCname">
              <el-input v-model="detailForm.address" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="机构:" prop="productCname">
              <el-input v-model="detailForm.branchCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="支付订单号:" prop="productCname">
              <el-input v-model="detailForm.paymentNo" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="旅行目的地:" prop="productCname">
              <el-input v-model="detailForm.travelDestination" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="落地分公司:" prop="productCname">
              <el-input v-model="detailForm.branchOffice" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="成功跳转地址:" prop="productCname">
              <el-input v-model="detailForm.successfulUrl" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="出单员:" prop="productCname">
              <el-input v-model="detailForm.singleMember" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道:" prop="productCname">
              <el-input v-model="detailForm.saleType" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单来源标识:" prop="productCname">
              <el-input v-model="detailForm.shareUid" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="回调地址:" prop="productCname">
              <el-input v-model="detailForm.callBackUrl" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="车架号:" prop="productCname">
              <el-input v-model="detailForm.frameNum" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="车牌号:" prop="productCname">
              <el-input v-model="detailForm.plateNum" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="条款地址:" prop="productCname">
              <el-input v-model="detailForm.clauseUrl" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="描述:" prop="productCname">
              <el-input v-model="detailForm.destination" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="房屋地址:" prop="productCname">
              <el-input v-model="detailForm.houseAddress" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="房屋类型:" prop="productCname">
              <el-input v-model="detailForm.houseType" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保城市:" prop="productCname">
              <el-input v-model="detailForm.insureCity" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="发票类型:" prop="productCname">
              <el-input v-model="detailForm.invoiceStatus" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保单号:" prop="productCname">
              <el-input v-model="detailForm.proposalNo" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="计划编号:" prop="productCname">
              <el-input v-model="detailForm.planCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="计划名称:" prop="productCname">
              <el-input v-model="detailForm.planName" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="交易ID:" prop="productCname">
              <el-input v-model="detailForm.dealUuid" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="保单号:" prop="productCname">
              <el-input v-model="detailForm.policyNo" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位名称:" prop="customName">
              <el-input v-model="detailForm.customName" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位类型:" prop="channelType">
              <el-input v-model="detailForm.channelType" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="归属机构代码:" prop="channelCode">
              <el-input v-model="detailForm.channelCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="归属机构名称:" prop="channelName">
              <el-input v-model="detailForm.channelName" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="代理人:" prop="agentName">
              <el-input v-model="detailForm.agentName" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="附加信息:" prop="additionalInfo">
              <el-input v-model="detailForm.additionalInfo" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="detailFormVisible = false">取消</el-button>
        <!-- <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button> -->
      </div>
    </el-dialog>
    <!--修改界面-->
    <el-dialog title="修改" size="large" v-model="editFormVisible" :close-on-click-modal="false">
      <el-form :model="editForm" label-width="120px" ref="editForm">
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单ID:" prop="productCname">
              <el-input v-model="editForm.id" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单号:" prop="productCname">
              <el-input v-model="editForm.orderNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户编码:" prop="productCname">
              <el-input v-model="editForm.userId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码:" prop="productCname">
              <el-input v-model="editForm.agreementNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="状态:" prop="productCname">
              <!--  list[i].status = commons.guarantStaus(list[i].status); -->
              <!-- <el-input v-model="editForm.status" auto-complete="off"></el-input> -->
              <el-select clearable v-model="editForm.status">
                <el-option v-for="(item,index) in statusList" :key="index" :label="item.val" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="保费:" prop="productCname">
              <el-input v-model="editForm.amount" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="险种:" prop="productCname">
              <el-input v-model="editForm.riskCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="计划编号:" prop="productCname">
              <el-input v-model="editForm.planCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保人:" prop="productCname">
              <el-input v-model="editForm.applicantName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保人证件号:" prop="productCname">
              <el-input v-model="editForm.idNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="起保时间:" prop="productCname">
              <el-input v-model="editForm.startDate" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="终保时间:" prop="productCname">
              <el-input v-model="editForm.endDate" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--               <el-row v-for="(item,index) in detailForm.applicant">
              <el-col :xs="20" :sm="12" :md="6" :lg="6">
                <el-form-item :label="'被保人'+(index+1)+':'"  prop="productCname">
                    <el-input v-model="item.name" :readonly='true' auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="20" :sm="12" :md="6" :lg="6">
                <el-form-item :label="'被保人'+(index+1)+'证件号:'"  prop="productCname">
                    <el-input v-model="item.carId" :readonly="true" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="20" :sm="12" :md="6" :lg="6">
                <el-form-item :label="'被保人'+(index+1)+'职业:'"  prop="productCname">
                    <el-input v-model="item.occupation" :readonly='true' auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="20" :sm="12" :md="6" :lg="6">
                <el-form-item :label="'被保人'+(index+1)+'手机号:'"  prop="productCname">
                    <el-input v-model="item.mobil" :readonly="true" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              </el-row> -->
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单创建时间:" prop="productCname">
              <el-input v-model="editForm.createTime" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单更新时间:" prop="productCname">
              <el-input v-model="editForm.updateTime" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单支付时间:" prop="productCname">
              <el-input v-model="editForm.payDate" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="备注:" prop="productCname">
              <el-input v-model="editForm.remark" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单详情:" prop="productCname">
              <el-input v-model="editForm.orderDetail" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="产品名:" prop="productCname">
              <el-input v-model="editForm.productName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐人:" prop="productCname">
              <el-input v-model="editForm.refereeId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="房屋所在地:" prop="productCname">
              <el-input v-model="editForm.address" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="机构:" prop="productCname">
              <!-- <el-input v-model="editForm.branchCode" auto-complete="off"></el-input> -->
              <el-select clearable v-model="editForm.branchCode" placeholder="请选择选择机构">
                <el-option v-for="(item,index) in items" :key="index" :label="item.codeCname" :value="item.code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="支付订单号:" prop="productCname">
              <el-input v-model="editForm.paymentNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="旅行目的地:" prop="productCname">
              <el-input v-model="editForm.travelDestination" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="落地分公司:" prop="productCname">
              <el-input v-model="editForm.branchOffice" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="成功跳转地址:" prop="productCname">
              <el-input v-model="editForm.successfulUrl" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="出单员:" prop="productCname">
              <el-input v-model="editForm.singleMember" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道:" prop="productCname">
              <el-input v-model="editForm.saleType" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="订单来源标识:" prop="productCname">
              <el-input v-model="editForm.shareUid" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="回调地址:" prop="productCname">
              <el-input v-model="editForm.callBackUrl" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="车架号:" prop="productCname">
              <el-input v-model="editForm.frameNum" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="车牌号:" prop="productCname">
              <el-input v-model="editForm.plateNum" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="条款地址:" prop="productCname">
              <el-input v-model="editForm.clauseUrl" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="描述:" prop="productCname">
              <el-input v-model="editForm.destination" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="房屋地址:" prop="productCname">
              <el-input v-model="editForm.houseAddress" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="房屋类型:" prop="productCname">
              <el-input v-model="editForm.houseType" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保城市:" prop="productCname">
              <el-input v-model="editForm.insureCity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="发票类型:" prop="productCname">
              <el-input v-model="editForm.invoiceStatus" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="投保单号:" prop="productCname">
              <el-input v-model="editForm.proposalNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="计划编号:" prop="productCname">
              <el-input v-model="editForm.planCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="计划名称:" prop="productCname">
              <el-input v-model="editForm.planName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="交易ID:" prop="productCname">
              <el-input v-model="editForm.dealUuid" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="保单号:" prop="productCname">
              <el-input v-model="editForm.policyNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="支付方式:" prop="productCname">
              <el-select v-model="editForm.payWay" placeholder="请选择支付方式">
                <el-option label="刷卡" value="1"></el-option>
                <el-option label="网银转账" value="2"></el-option>
                <el-option label="支票" value="3"></el-option>
                <el-option label="现金" value="4"></el-option>
                <el-option label="内部转账" value="5"></el-option>
                <el-option label="在线支付" value="7"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="editFormVisible = false">取消</el-button>
        <el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
      </div>
    </el-dialog>
    <!-- -->
    <el-dialog title="回调" size="tiny" v-model="callBackVisible" :close-on-click-modal="false">
      <el-form label-width="80px" :model="callBackForm" ref="callBackForm">
        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="24">
            <el-form-item label="订单号:">
              <el-input v-model.trim="callBackForm.documentNo" style="width:100%;" auto-complete="off" placeholder="请输入订单号">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" align="center" class="dialog-footer">
        <el-button @click.native="callBackVisible = false">取消</el-button>
        <el-button type="primary" @click.native="callBackSubmit">回调</el-button>
      </div>
    </el-dialog>
    <!--匹配界面-->
    <el-dialog title="匹配" size="tiny" v-model="matchFormVisible" :close-on-click-modal="false">
      <el-form :model="matchForm" label-width="100px" ref="matchForm" :rules="matchFormRules" :inline="true">
        <el-form-item>
          <el-input size="small" style="width:200px;" v-model.trim="matchForm.matchCode" placeholder="请输入匹配码"></el-input>
        </el-form-item>
        <el-form-item style="float:right;">
          <el-button size="small" type="primary" v-on:click="match(matchForm.matchCode)">匹配</el-button>
        </el-form-item>
        <el-card class="box-card" v-show="uploadPass">
          <el-row>
            <el-col :xs="24" :sm="24" :md="24" :lg="24">
              <el-form-item label="用户编码:" prop="userCode">
                <el-input v-model.trim="matchForm.userCode" auto-complete="off" placeholder="请输入用户编码">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24">
              <el-form-item label="密码:">
                <el-input v-model.trim="matchForm.password" auto-complete="off" placeholder="请输入密码">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col align="center">
              <el-button type="primary" @click.native="matchSubmit" :loading="matchLoading">提交</el-button>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
    </el-dialog>
  </section>
</template>

<script>
import util from '../../common/js/util'
import commons from '../../common/js/common'
//import NProgress from 'nprogress'
import { mapState, mapActions } from 'vuex'
import { orderList, codeNodeList, callBackUrl, upOrder, updatePwdByUserCode, findAllHotArea, orderAuth, treeNextChannelList } from '../../api/api';

export default {
  data() {
    return {
      
      filters: {
        insuranceDate: '',
        payDate: '',
        policyNo: '',
        proposalNo: '',
        planName: '',
        paymentNo: '',
        agreementNo: '',
        branchCode: '',
        riskCode: '',
        productname: '',
        status: '',
        refereeId: '',
        barchCodes: '',
        riskCodes: '',
        applicantName: '',
        idNo: '',
        insureSelect: '1',
        insureData: '',
        InsuredData: '',
        createTime: '',
        InsuredSelect: '1',
        shareUid: '',
        callBackUrl: '',
        successfulUrl: '',
        orderNo: '',
        dealUuid: '',
        refereeMobile: '',
        unitType: '',
        userName: '',
        mobile: '',
        scoreUserName: '',
        scoreUserMobile: ''
      },
      // pickerOptions0: {
      //   disabledDate(time) {
      //     console.log(this.filters.payDate);
      //     return time.getTime() < Date.now() - 8.64e7;
      //   }
      // },  
      items: [],
      riskCodes: '',
      // Codelist:'',
      matchLoading: false,
      matchFormVisible: false,
      detailFormVisible: false,//显示详情
      editFormVisible: false,
      callBackVisible: false,
      listLoading: false,
      editLoading: false,
      exportTotal: 0,
      lists: [],
      loading: '',
      detailForm: {
        applicant: {
          name: '',
          carId: ''
        },
        branchCode: '',
      },
      editForm: {},
      treedata: [],
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      matchFormRules: {
        userCode: [
          { required: true, message: '请输入用户编码', trigger: 'blur' }
        ]
        // ,
        // password: [
        //   { required: true, message: '请输入密码', trigger: 'blur' }
        // ]
      },
      matchForm: {
        matchCode: '',
        userCode: '',
        password: ''
      },
      uploadPass: false,
      callBackForm: {
        documentNo: ''
      },
      orders: [],
      total: 0,
      page: 1,
      pageSize: 10,
      listLoading: false,
      avgAmount: '',
      totalAmount: '',
      sels: [],//列表选中列
      comCode: '',
      statusList: [],

      queryBtnVisible: false,
      resetBtnVisible: false,
      exportBtnVisible: false,
      syntonyBtnVisible: false,
      detailBtnVisible: false,
      updateBtnVisible: false
    }
  },
  computed: mapState({
    clist: 'riskCodelist',
    blist: 'branchCodelist',
    Tourl: 'skipUrl',
    IsFirstURl: 'IsFirstURl',
    winHeight: 'winHeight',
    hotAreaList: 'hotAreaList'
  }),
  methods: {
    ...mapActions([
      'CodeList', 'editIsfirst', 'findHotAreaList'
    ]),
    //险种编码转换
    formatRisk: function (row, column) {
      return commons.CodeName(this.clist, row.riskCode, 'RiskCode');
    },
    formatCreateTime: function (row, column) {
      return commons.getDaytime(row.createTime, 1, false);
    },
    //推荐人ID
    formatRefereeId: function (row, column) {
      if (row.refereeUser) {
        return row.refereeUser.userCode;
      }
      else {
        return null;
      }

    },
    //用户姓名
    formatUserName: function (row, column) {
      if (row.user) {
        return row.user.userName;
      }
      else {
        return null;
      }
    },
    //用户手机号码
    formatUserMobile: function (row, column) {
      if (row.user) {
        return row.user.mobile;
      }
      else {
        return null;
      }
    },
    //积分用户
    formatScoreUserName: function (row, column) {
      if (row.refereeUser) {
        return row.refereeUser.userName;
      }
      else {
        return null;
      }

    },
    // hasScoreUser: function (row, column) {
    //   return row.scoreU;
    // },
    //积分用户手机号
    formatScoreUserMobile: function (row, column) {
      if (row.refereeUser) {
        return row.refereeUser.mobile;
      }
      else {
        return null;
      }

    },
    //推荐人手机号
    formatRefereeMobile: function (row, column) {
      if (row.refereeUser) {
        return row.refereeUser.mobile;
      }
      else {
        return null;
      }

    },
    //客户单位类型
    formatUnitType: function (row, column) {


    },
    dateChange: function (date) {
      console.log(date[0]);
console.log(date[1]);
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getOrders(true);
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.getOrders(true);
    },
    //重置
    getdelete() {
      this.filters = {
        insuranceDate: '',
        payDate: '',
        policyNo: '',
        proposalNo: '',
        planName: '',
        paymentNo: '',
        agreementNo: '',
        branchCode: '',
        riskCode: '',
        productname: '',
        status: '',
        refereeId: '',
        barchCodes: '',
        riskCodes: '',
        applicantName: '',
        idNo: '',
        insureSelect: '1',
        insureData: '',
        InsuredData: '',
        createTime: '',
        InsuredSelect: '1',
        shareUid: '',
        callBackUrl: '',
        successfulUrl: '',
        orderNo: '',
        dealUuid: '',
        refereeMobile: '',
        userName: '',
        mobile: '',
        scoreUserName: '',
        scoreUserMobile: ''
      };
    },
    //获取订单列表
    getOrders(bool) {
      console.log(this.filters.payDate);
      if (!bool) {
        if (!this.filters.createTime&&!this.filters.payDate&&!this.filters.insuranceDate) {
          this.$message({
             message: "请先选择任一日期范围！",
             type: 'error'
          });
          return;
        } else if ((!this.filters.createTime[0]||!this.filters.createTime[1])
               &&(!this.filters.payDate[0]||!this.filters.payDate[1])
               &&(!this.filters.insuranceDate[0]||!this.filters.insuranceDate[1])) {
          this.$message({
             message: "请先选择任一日期范围！",
             type: 'error'
          });
          return;
        }

        if (this.filters.insuranceDate) {
            var oneTime = new Date().setTime(new Date(this.filters.insuranceDate[0]).getTime());
            var twoTime = new Date().setTime(new Date(this.filters.insuranceDate[1]).getTime());
            if( oneTime + 3600 * 1000 * 24 * 31 < twoTime){ //判断开始时间+30天是否小于结束时间     
              this.filters.payDate = [];     
              this.$alert(
                '日期范围最大为31天', 
                '温馨提示', {     
                      confirmButtonText: '确定',
                      type: 'info'
                });
              return;
            }
        }
        if (this.filters.createTime) {
            var oneTime = new Date().setTime(new Date(this.filters.createTime[0]).getTime());
            var twoTime = new Date().setTime(new Date(this.filters.createTime[1]).getTime());
            if( oneTime + 3600 * 1000 * 24 * 31 < twoTime){ //判断开始时间+30天是否小于结束时间     
              this.filters.payDate = [];     
              this.$alert(
                '日期范围最大为31天', 
                '温馨提示', {     
                      confirmButtonText: '确定',
                      type: 'info'
                });
              return;
            }
        }
        if (this.filters.payDate) {
            var oneTime = new Date().setTime(new Date(this.filters.payDate[0]).getTime());
            var twoTime = new Date().setTime(new Date(this.filters.payDate[1]).getTime());
            if( oneTime + 3600 * 1000 * 24 * 31 < twoTime){ //判断开始时间+30天是否小于结束时间     
              this.filters.payDate = [];     
              this.$alert(
                '日期范围最大为31天', 
                '温馨提示', {     
                      confirmButtonText: '确定',
                      type: 'info'
                });
              return;
            }
        }
      }
      var d = new Date(this.filters.startTime);
      let para = new FormData();
      para.append("pageSize", bool ? this.pageSize : this.exportTotal);
      para.append("pageNumber", bool ? this.page : 1);
      para.append("insuranceDateStart", commons.changeTimes(this.filters.insuranceDate, 'start'));
      para.append("insuranceDateEnd", commons.changeTimes(this.filters.insuranceDate, 'end'));
      para.append("payDateStart", commons.changeTimes(this.filters.payDate, 'start'));
      para.append("payDateEnd", commons.changeTimes(this.filters.payDate, 'end'));
      para.append("createTimeStart", commons.changeTimes(this.filters.createTime, 'start'));
      para.append("createTimeEnd", commons.changeTimes(this.filters.createTime, 'end'));
      para.append("policyNo", this.filters.policyNo);
      para.append("proposalNo", this.filters.proposalNo);
      para.append("planName", this.filters.planName);
      para.append("applicantName", this.filters.insureSelect == '1' ? this.filters.insureData : '');
      para.append("idNo", this.filters.insureSelect == '2' ? this.filters.insureData : '');
      para.append("insuredPersonName", this.filters.InsuredSelect == '1' ? this.filters.InsuredData : '');
      para.append("insuredPersonNo", this.filters.InsuredSelect == '2' ? this.filters.InsuredData : '');
      para.append("paymentNo", this.filters.paymentNo);
      para.append("agreementNo", this.filters.agreementNo);
      para.append("branchCode", this.filters.branchCode);
      para.append("riskCode", this.filters.riskCode);
      para.append("refereeId", this.filters.refereeId);
      para.append("productName", this.filters.productname);
      para.append("status", this.filters.status);
      para.append("shareUid", this.filters.shareUid);
      para.append("callBackUrl", this.filters.callBackUrl);
      para.append("successfulUrl", this.filters.successfulUrl);
      para.append("orderNo", this.filters.orderNo);
      para.append("dealUuid", this.filters.dealUuid);
      para.append("refereeMobile", this.filters.refereeMobile);
      para.append("userName", this.filters.userName);
      para.append("mobile", this.filters.mobile);
      para.append("scoreUserName", this.filters.scoreUserName);
      para.append("scoreUserMobile", this.filters.scoreUserMobile);
      para.append("comCode", commons.isEmpty(this.comCode)?"00000000":this.comCode);
      // para.append('comCode', this.comCode);
      this.listLoading = bool;
      //NProgress.start();
      if (!bool) {
        this.loading = this.$loading({
          lock: true,
          text: '正在导出',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      }
      orderList(para).then((res) => {
        this.total = res.data.result.totalSize;
        this.exportTotal = res.data.result.totalSize;
        this.lists = res.data.result.list;
        this.avgAmount = res.data.result.avgAmount;
        this.totalAmount = res.data.result.totalAmount;
        this.listLoading = false;
        if (!bool) {
          this.loading.close();
          this.export2Excel();
        }
        else {
          this.orders = res.data.result.list;
          for (var i in this.orders) {
            this.orders[i].names = res.data.result.content[i].applicant.name;
            this.orders[i].carIds = res.data.result.content[i].applicant.carId;
          }
        }
        //NProgress.done();
      }).catch(() => {
        if (!bool) {
          this.$message({
            message: '导出异常',
            type: 'error'
          });
          this.loading.close();
        }

      });
      let branchList = new FormData();

      branchList.append("type", "BranchCode");

      codeNodeList(branchList).then((res) => {
        this.filters.barchCodes = res.data.result;

      });

      let riskList = new FormData();

      riskList.append("type", "RiskCode");

      codeNodeList(riskList).then((res) => {
        this.filters.riskCodes = res.data.result;
        this.riskCodes = res.data.result;
      });
    },

    //table导出excel
    exportExcels: function () {
      this.getOrders(false);
    },
    export2Excel: function () {
      require.ensure([], () => {
        const { export_json_to_excel } = require('../../vendor/Export2Excel');
        let tHeader = ['订单ID', '订单号', '积分计提用户编码', '积分计提用户姓名', '积分计提用户手机号','积分用户获得积分', '用户编码', '用户姓名', '用户手机号', '订单状态', '原保费', '保费', '险种', '计划编号', '计划名称', '投保人', '起保时间', '终保时间', '订单创建时间', '订单更新时间', '备注', '产品名', '机构', '房屋所在地', '保单号', '投保单号', '支付订单号', '支付时间', '业务关系代码', '销售渠道', '支付方式', '推荐人', '推荐人姓名', '推荐人电话', '旅行目的地', '落地分公司', '车架号', '车牌号', '被保人1姓名', '被保人1职业类别', '被保人1证件类型', '被保人1证件号', '被保人1手机号', '被保人1邮箱', '客户单位名称', '客户单位类型', '归属机构代码', '归属机构名称', '代理人','第1级姓名','第1级获得积分'];
        let filterVal = ['id', 'orderNo', 'refereeId', 'refereeUserName', 'refereeUserMobile', 'scoreIn','userId', 'userName', 'mobile', 'status', 'oldPremium', 'amount', 'riskCode', 'planCode', 'planName', 'applicantName', 'startDate', 'endDate', 'createTime', 'updateTime', 'remark', 'productName', 'branchCode', 'address', 'policyNo', 'proposalNo', 'paymentNo', 'payDate', 'agreementNo', 'saleType', 'payWay', 'refereeId', 'refereeUserName', 'refereeUserMobile', 'travelDestination', 'branchOffice', 'frameNum', 'plateNum', 'applicantName1', 'applicantOccupationType1', 'applicantCarType1', 'applicantCarId1', 'applicantMobil1', 'applicantEmail1', 'customName', 'channelType', 'channelCode', 'channelName', 'agentName','levelName1','levelScore1'];
        const list = this.lists;
        let brCode = '';
        for (var i in list) {
          list[i].status = commons.guarantStaus(list[i].status);
          list[i].payWay = commons.payTypes(list[i].payWay);
          list[i].riskCode = commons.CodeName(this.clist, list[i].riskCode, "RiskCode");
          brCode = list[i].branchCode;
          list[i].branchCode = commons.Branchs(list[i].branchCode);
          if (list[i].branchCode == brCode) {
            list[i].branchCode = commons.hotArea(brCode, this.hotAreaList);
          }
          list[i].refereeUserName = '';
          list[i].refereeUserMobile = '';
          list[i].refereeId = '';
          list[i].userName = '';
          list[i].mobile = '';
          if (list[i].refereeUser) {
            list[i].refereeUserName = list[i].refereeUser.userName;
            list[i].refereeUserMobile = list[i].refereeUser.mobile;
            list[i].refereeId = list[i].refereeUser.userCode;
            list[i].scoreIn = list[i].refereeUser.baseRate;
          }
          if (list[i].user) {
            list[i].userName = list[i].user.userName;
            list[i].mobile = list[i].user.mobile;
            list[i].channelCode = list[i].user.channelCode;
            list[i].channelName = list[i].user.channelName;
          }
          if (list[i].applicant) {
            let tHeaderLength = tHeader.length;
            let applicants = list[i].applicant;
            let temp = tHeader[tHeaderLength - 1].substring(3, 4);
            for (var k = 1; k <= applicants.length; k++) {
              var applicantName = 'applicantName' + k;
              var applicantOccupationType = 'applicantOccupationType' + k;
              var applicantCarType = 'applicantCarType' + k;
              var applicantCarId = 'applicantCarId' + k;
              var applicantMobil = 'applicantMobil' + k;
              var applicantEmail = 'applicantEmail' + k;
              if (parseInt(temp) < k) {
                tHeader.push('被保人' + k + '姓名');
                tHeader.push('被保人' + k + '职业类别');
                tHeader.push('被保人' + k + '证件类型');
                tHeader.push('被保人' + k + '证件号');
                tHeader.push('被保人' + k + '手机号');
                tHeader.push('被保人' + k + '邮箱');
                filterVal.push('applicantName' + k);
                filterVal.push('applicantOccupationType' + k);
                filterVal.push('applicantCarType' + k);
                filterVal.push('applicantCarId' + k);
                filterVal.push('applicantMobil' + k);
                filterVal.push('applicantEmail' + k);
              }
              list[i][applicantName] = applicants[k - 1].name;
              list[i][applicantOccupationType] = applicants[k - 1].occupation;
              list[i][applicantCarType] = commons.applicantCarType(applicants[k - 1].carType);
              list[i][applicantCarId] = applicants[k - 1].carId;
              list[i][applicantMobil] = applicants[k - 1].mobil;
              list[i][applicantEmail] = applicants[k - 1].email;
            }
          }

          //上级渠道获得积分
          if (list[i].upUserSocre) {
            let tHeaderLength = tHeader.length;
            let upUserSocres = list[i].upUserSocre;
            
            let temp = tHeader[tHeaderLength - 1].substring(1, 2);
            for (var k = 1; k <= upUserSocres.length; k++) {
              if (!commons.isEmpty(upUserSocres[k-1])) {
                var levelName = 'levelName' + k;
                var levelScore = 'levelScore' + k;
                if (parseInt(temp) < k) {
                  tHeader.push('第' + k + '级姓名');
                  tHeader.push('第' + k + '级获得积分');
                  filterVal.push('levelName' + k);
                  filterVal.push('levelScore' + k);
                }
                console.log(upUserSocres[k - 1][5])
                list[i][levelName] = upUserSocres[k - 1][20];
                list[i][levelScore] = upUserSocres[k - 1][3];
              }
            } 
          }


        }
        const data = this.formatJson(filterVal, list);
        export_json_to_excel(tHeader, data, '订单列表excel');
      })
    },
    formatJson: function (filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => v[j]))
    },

    //详情
    handleDetail: function (index, row) {
      this.detailForm = Object.assign({}, row);
      this.detailFormVisible = true;
      this.detailForm.status = commons.guarantStaus(row.status);
      this.detailForm.riskCode = commons.CodeName(this.clist, row.riskCode, "RiskCode");
      if (row.user) {
        this.detailForm.channelCode = row.user.channelCode;
        this.detailForm.channelName = row.user.channelName;
      } else {
        this.detailForm.channelCode = null;
        this.detailForm.channelName = null;
      }

      if (row.refereeUser) {
        this.detailForm.refereeId = row.refereeUser.userCode;
      }
      else {
        this.detailForm.refereeId = null;
      }

      for (var i in this.filters.barchCodes) {
        if (row.branchCode == this.filters.barchCodes[i].code) {
          this.detailForm.branchCode = this.filters.barchCodes[i].codeCname;
        }
      }
    },
    //修改
    handleEdit: function (index, row) {
      this.editFormVisible = true;
      this.editForm = Object.assign({}, row);
      let brCode = '';
      brCode = row.branchCode;
      this.editForm.branchCode = commons.Branchs(row.branchCode);
      if (row.branchCode == brCode) {
        row.branchCode = commons.hotArea(brCode, this.hotAreaList);
      }
    },
    //修改提交
    editSubmit: function () {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.editLoading = true;
            let para = Object.assign({}, this.editForm);
            upOrder(para).then((res) => {
              this.editLoading = false;
              if (res.data.success) {
                this.$message({
                  message: '提交成功',
                  type: 'success'
                });
                this.$refs['editForm'].resetFields();
                this.editFormVisible = false;
                this.getOrders(true);
              }
              else {
                this.$message({
                  message: res.data.result,
                  type: 'error'
                });
              }
            }).catch(() => {
              this.editLoading = false;
            });
          });
        }
      });
    },
    getpass() {
      this.matchFormVisible = true;
      this.matchForm = {
        matchCode: '',
        userCode: '',
        password: ''
      };
      this.uploadPass = false;
      this.$refs['matchForm'].resetFields();
    },
    match: function (code) {
      if (code == "000000") {
        this.uploadPass = true;
      }
      else {
        this.$message({
          message: "匹配失败",
          type: 'error'
        });
      }
      this.matchForm.matchCode = "";
    },
    matchSubmit: function () {
      this.$refs.matchForm.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.matchLoading = true;
            let para = new FormData();
            para.append("userCode", this.matchForm.userCode);
            para.append("password", this.matchForm.password);
            updatePwdByUserCode(para).then((res) => {
              if (res.data.success) {
                this.$message({
                  message: res.data.result,
                  type: 'success'
                });
                this.matchFormVisible = false;
                this.$refs['matchForm'].resetFields();
              }
              else {
                this.$message({
                  message: res.data.result,
                  type: 'error'
                });
              }
              this.matchLoading = false;
            }).catch(() => {
              this.matchLoading = false;
            });
          });
        }
      });
    },
    selsChange: function (sels) {
      this.sels = sels;
    },
    //回调
    getcallBack: function () {
      this.callBackVisible = true;
      this.callBackForm = {
        documentNo: ''
      }
    },
    callBackSubmit: function () {
      let para = {
        documentNo: this.callBackForm.documentNo,
        isJump: false
      };
      callBackUrl(para).then((res) => {
        this.callBackVisible = false;
      }).catch(() => {

      });
    },

    btnShow: function () {
      let thisData = JSON.parse(sessionStorage.getItem('151'));
      let _this = this;
      $.each(thisData, function (i, j) {
        if (thisData[i] == "orderQuery") {
          _this.queryBtnVisible = true;
        }
        if (thisData[i] == "orderReset") {
          _this.resetBtnVisible = true;
        }
        if (thisData[i] == "orderExport") {
          _this.exportBtnVisible = true;
        }
        if (thisData[i] == "orderCallback") {
          _this.syntonyBtnVisible = true;
        }
        if (thisData[i] == "orderDetail") {
          _this.detailBtnVisible = true;
        }
        if (thisData[i] == "orderUpdate") {
          _this.updateBtnVisible = true;
        }
      });
    },

    beforeMount() {
    },
    handleNodeClick: function (data, node, obj) {
      this.comCode = data.id;
      let para = new FormData();
      para.append('branchNo', data.id);
      para.append('type', 'order');
      treeNextChannelList(para).then((res) => {
        if (res.data.result && res.data.success == true) {
          for (let i in res.data.result) {
            const newChild = { id: res.data.result[i].userCode, label: res.data.result[i].shopName, children: [] };
            if (!data.children) {
              this.$set(data, 'children', []);
            }
            if (typeof (commons.GetByID(this.treedata, res.data.result[i].userCode)) == 'undefined') {
              data.children.push(newChild);
            }
          }
        }
      });
      this.getOrders(true);
    },

    getSelectPerTree: function () {
      let para = new FormData();
      var userinfo = sessionStorage.getItem('user');
      if (userinfo) {
        var user = JSON.parse(userinfo);
      }
      var userid = user.userId;
      para.append('userId', userid);
      para.append('type', 'order');
      let modelTree = this.treedata;
      let leafTree = [];
      orderAuth(para).then((res) => {
        var data = res.data.result;
        if (data) {
          this.comCode=data[0].branchNo;
        }
        gettree(data, this.treedata);
        console.log(this.treedata)
      });
      function gettree(arr, trees) {
        for (var i in arr) {
          if (typeof (commons.GetByID(trees, arr[i].branchNo)) == 'undefined') {
            trees.push({
              id: arr[i].branchNo,
              label: arr[i].branchCname,
              children: []
            });
          }
          if (arr[i].nextBranch) {
            let childTree = commons.GetByID(trees, arr[i].branchNo);
            gettree(arr[i].nextBranch, childTree.children);
          }
        }
      }
       // setTimeout(() => {
        this.getOrders(true);
      // }, 1000);
    },
  },
  mounted() {
    this.btnShow();
    this.findHotAreaList();
    this.getSelectPerTree();
    this.items = this.blist.result;
    this.statusList.push(
      { 'id': '0', 'val': '支付失败' },
      { 'id': '1', 'val': '已支付' },
      { 'id': '2', 'val': '未支付' },
      { 'id': '3', 'val': '无效' },
      { 'id': '4', 'val': '新保' },
      { 'id': '5', 'val': '下发修改或拒保' },
      { 'id': '6', 'val': '自动核保' },
      { 'id': '7', 'val': '等待核保' },
      { 'id': '8', 'val': '主动撤回' },
      { 'id': '9', 'val': '查勘岗' },
      { 'id': '10', 'val': '单证审核不通过' },
      { 'id': '11', 'val': '待单证审核' },
      { 'id': '12', 'val': '待绩效审核' },
      { 'id': '13', 'val': '绩效审核不通过' },
      { 'id': '14', 'val': '批退' },
      { 'id': '15', 'val': '批改' },
      { 'id': '16', 'val': '保单遗失' },
      { 'id': '17', 'val': '保单注销' },
    )
  }
}

</script>

<style scoped>
.el-tree{
  border:0px ;
}
/*.el-select {
    width: 135px;
  }*/
.toolbar {
  padding-bottom: 10px !important;
}
.toolbar .el-form-item {
  margin-bottom: 0px;
}
.detailLabel {
  /*float:left;*/
  display: inline-block;
  text-align: right;
  width: 120px;
  color: #0b80da;
  font-weight: bold;
}
</style>